2: Create Schema
Only the Governance
role can create Schemas. Note that the Authorization: Bearer <Token>
used in the following request is purposefully obfuscated as DIDx will act as Governance
.
curl -X 'POST' \
'https://cloudapi.test.didxtech.com/governance/v1/definitions/schemas' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: ***' \
-d '{
"name": "Person",
"version": "0.1.0",
"attribute_names": [
"Name","Surname","Age"
]
}'
Response:
{
"id": "QpSW24YVf61A3sAWxArfF6:2:Person:0.1.0",
"name": "Person",
"version": "0.1.0",
"attribute_names": ["Surname", "Age", "Name"]
}
Note: Trying to recreate a schema that already exists will simply return the existing schema payload.
Fetching existing schemas
Governance is a privileged role, and so everyone else can view existing schemas by calling the /v1/trust-registry/schemas
endpoint on CloudAPI-Public, and viewing corresponding schema attributes by calling /v1/definitions/schemas/{schema_id}
on CloudAPI-Tenant or on the ledger browser (you can filter by type: SCHEMAS
to navigate more easily).
Fetch trust registry schemas request (Public endpoint no authorization required):
curl -X 'GET' \
'https://cloudapi.test.didxtech.com/public/v1/trust-registry/schemas' \
-H 'accept: application/json'
The response is a list of existing schemas:
[
{
"did": "GXK1Ubc58DvZDe48zPYdcf",
"name": "Proof of Person",
"version": "0.1.0",
"id": "GXK1Ubc58DvZDe48zPYdcf:2:Proof of Person:0.1.0"
},
{
"did": "GXK1Ubc58DvZDe48zPYdcf",
"name": "Proof of Address",
"version": "0.1.0",
"id": "GXK1Ubc58DvZDe48zPYdcf:2:Proof of Address:0.1.0"
},
...
]
Get schema by id
as tenant
curl -X 'GET' \
'https://cloudapi.test.didxtech.com/tenant/v1/definitions/schemas/GXK1Ubc58DvZDe48zPYdcf%3A2%3APerson_1%3A0.1.0' \
-H 'x-api-key: tenant.ey...'
-H 'accept: application/json'
Response of getting schema by id
{
"id": "GXK1Ubc58DvZDe48zPYdcf:2:Person_1:0.1.0",
"name": "Person_1",
"version": "0.1.0",
"attribute_names": ["Name", "Surname", "Age"]
}
In the ledger browser, the id
above (schema id) will map to the transaction_id
on the ledger, and there you can see the attributes for any given schema.